package com.wx.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.mvc.LastModified;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LastModifiedController implements Controller, LastModified {

	private long lastModified;

	@Override
	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("simple");
		mv.addObject("name", "LastModified");
		return mv;
	}

	@Override
	public long getLastModified(HttpServletRequest request) {

		if (this.lastModified == 0L) {
			this.lastModified = System.currentTimeMillis();
		}
		return this.lastModified;
	}
}
